
#ifndef APPLE_APP_STUB_H
#define APPLE_APP_STUB_H

#ifdef  __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <stdint.h>

typedef signed char             int8;
typedef signed short            int16;
typedef signed long             int32;
typedef signed long long        int64;
typedef unsigned char           uint8;
typedef unsigned short          uint16;
typedef unsigned long           uint32;
typedef unsigned long long      uint64;
typedef int            ipod_t;

typedef int32_t		StubAirPlayEntity;
#define kStubAirPlayEntity_NotApplicable			0
#define kStubAirPlayEntity_Controller				1
#define kStubAirPlayEntity_Accessory				2

// AirPlaySpeechMode

typedef int32_t		StubAirPlaySpeechMode;
#define kStubAirPlaySpeechMode_NotApplicable			0
#define kStubAirPlaySpeechMode_None						-1 // No speech-related states are active.
#define kStubAirPlaySpeechMode_Speaking					1  // Device is speaking to the user.
#define kStubAirPlaySpeechMode_Recognizing				2  // Device is recording audio to recognize speech from the user.


// State

typedef struct
{
	StubAirPlayEntity			entity;
	StubAirPlaySpeechMode		mode;

}	StubAirPlaySpeechState;

typedef struct
{
	StubAirPlayEntity			screen;			// Current user of the screen.
	StubAirPlayEntity			permScreen;		// Permanent owner of screen.
	StubAirPlayEntity			mainAudio;		// Current user of main audio.
	StubAirPlayEntity			permMainAudio;	// Permanent owner of main audio.
	StubAirPlayEntity			phoneCall;		// Owner of phone call.
	StubAirPlaySpeechState		speech;			// Owner of speech and its mode.
	StubAirPlayEntity			turnByTurn;		// Owner of navigation.

}	StubAirPlayModeState;


int     startCarplay( int argc, char **argv );
int     stopCarplay( );
int     sendBluetoothRfcommData(int len, char * pData);
int     sendTouchScreenUpdate( uint8_t inPress, uint16_t inX, uint16_t inY );
int     sendKnobScreenUpdate(char selectButtonPressed, char homeButtonPressed, char backButtonPressed, double x,
                     double y, char wheelPositionRelative);

int     sendWiFiInformation(const char * ssid,const char * password);

//void	sendCarPlayChangeModeRequest(
//	const char *				inScreenBorrowID,
//	AirPlayTransferType 		inScreenType,
//	AirPlayTransferPriority		inScreenPriority,
//	AirPlayConstraint			inScreenTake,
//	AirPlayConstraint			inScreenBorrow,
//	const char *				inAudioBorrowID,
//	AirPlayTransferType 		inAudioType,
//	AirPlayTransferPriority		inAudioPriority,
//	AirPlayConstraint			inAudioTake,
//	AirPlayConstraint			inAudioBorrow,
//	AirPlayTriState				inPhone,
//	AirPlaySpeechMode			inSpeech,
//	AirPlayTriState				inTurnByTurn );
void sendCarPlayChangeModeRequest(
	const char *	inScreenBorrowID,
	int32_t 		inScreenType,
	int32_t		    inScreenPriority,
	int32_t			inScreenTake,
	int32_t			inScreenBorrow,
	const char *	inAudioBorrowID,
	int32_t 		inAudioType,
	int32_t		    inAudioPriority,
	int32_t			inAudioTake,
	int32_t			inAudioBorrow,
	int32_t		    inPhone,
	int32_t			inSpeech,
	int32_t			inTurnByTurn );

void sendCarPlayRequestUI();
void sendCarPlayRequestUIWithURL( const char * url );
void carplayAudioStreamOutputProcessData(int handle, void* inbuffer, int len, int frames, uint64_t timestamp);
void carplayAudioStreamInputProc(int handle, void* buffer, int len, int frame, uint64_t timestamp);
void carplaySetNightMode(int enter);
void sendCarPlaySiriButton(int pressed);
void sendCarPlayMediaButton(int button);
void sendCarPlayTelephonyUpdate(int inButtonIndex);
void sendCarPlayForceKeyFrame();


#ifdef  __cplusplus
}  
#endif
#endif //APPLE_APP_STUB_H
